<?php

class Component{
	public static function render($templateOrView, $bindings = NULL){

		$path = 'app/view/'.Config::$TEMPLATE .'/componentes/'.$templateOrView.'.phtml';
		
		if ($templateOrView === "json") {
			return OutputFormatter::convert($bindings);
		}
		
		if (file_exists($path)) {
			$templateOrView = file_get_contents($path);
		}
		
		if ($bindings != NULL) {
			$mustache = new Mustache();
			return $mustache->render($templateOrView, $bindings);
		} else {
			return $templateOrView;
		}
	}
}

?>